\begin{tikzpicture}

  \node at (-0.4, 1.2) {Process 1};
   \node at (4.2, 1.2) {Scheduler};
   \node at (8.5, 1.2) {Process 2};
   
 \node (code0) at (0,0) {
  \begin{lstlisting}[basicstyle=\tt\footnotesize]
  (*@\textcolor{blue}{acquire(\&p->lock);}@*)
  ...
  p->state = RUNNABLE;
  swtch(&p->context, ...);
  \end{lstlisting}

    %% this line is important
  };

  \node (code1) at (4.5,-3.0) {
    \begin{lstlisting}[basicstyle=\tt\footnotesize]
    swtch(...); // return
    (*@\textcolor{blue}{release(\&p->lock)};@*)

    // find a RUNNABLE p

    (*@\textcolor{green}{acquire(\&p->lock);}@*)
    p->state = RUNNING;
    swtch(...,&p->context);
    \end{lstlisting}

    %% this line is important
  };

    \node (code2) at (9.6,-5.5) {
      \begin{lstlisting}[basicstyle=\tt\footnotesize]
      swtch(&p->context,...); // return
      (*@\textcolor{green}{release(\&p->lock);}@*)
     \end{lstlisting}

    %% this line is important
  };

    \draw[->,thick] (1.2,-0.95) -- (2.5,-1.4);
    \draw[->,thick] (5.3,-4.75) -- (6.8,-5.2);
  
\end{tikzpicture}
